Xbasic

TOSECONDS Function

Syntax

Count as N = TOSECONDS(C character)

Arguments

character

A time value in one of the following formats:"h:m:s am/pm", "h:m:s", "h:m"

Description

Converts a time value to seconds.

Discussion

Converts a Formatted_Time containing a time value to an integer Count equal to the number of seconds past midnight. You typically use TOSECONDS() to perform time arithmetic to compute the elapsed time between a starting and ending time, or to compute an ending time from a start time and an elapsed time. The TOSECONDS() function supports fractional seconds, e.g. toseconds("3:23:05.23 pm").

Example

toseconds("23") ->  23
toseconds("12:23") ->  44,580
toseconds("2:3:15") ->  7,395
toseconds("2:3:15 PM") ->  50,595

Assume you stored the time at which an event started in a field called START, and the time at which the event ended in a field called end. To compute the duration of the event, you use the following expression:

toseconds(end) - toseconds(START)

See Also